import pymysql

class DatabaseHandler:
    def __init__(self, host, user, password, database):
        self.conn = pymysql.connect(host=host, user=user, password=password, database=database)
        self.cursor = self.conn.cursor()

    def create_table(self, table_name):
        query = f'''CREATE TABLE IF NOT EXISTS {table_name} (name VARCHAR(255), score INT)'''
        self.cursor.execute(query)

    def insert_data(self, data):
        for item in data:
            query = "INSERT INTO your_table (name, score) VALUES (%s, %s)"
            self.cursor.execute(query, item)

    def commit(self):
        self.conn.commit()

    def close(self):
        self.conn.close()

# 创建数据库操作对象
db_handler = DatabaseHandler('localhost', 'your_user', 'your_password', 'your_database')

# 创建表
db_handler.create_table('your_table')

zh = list(zip(name, score))

# 插入数据
db_handler.insert_data(zh)

# 提交事务
db_handler.commit()

# 关闭连接
db_handler.close()
